package com.swt.testdemo.controller;

import com.swt.testdemo.config.ResponseBean;
import com.swt.testdemo.form.QueryLogForm;
import com.swt.testdemo.form.UserLogChartForm;
import com.swt.testdemo.form.UserLogRateForm;
import com.swt.testdemo.service.SysLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author BleethNie
 * @version 1.0
 * @date 2020/11/12 10:59
 **/
@RestController
@RequestMapping("/sys/log")
@Api(tags = "后台管理--日志管理")
@Slf4j
public class SysLogController {

    @Autowired
    private SysLogService sysLogService;

    @ApiOperation("01 查看日志列表信息")
    @GetMapping(value = "/list")
    public ResponseEntity<ResponseBean> listLog(QueryLogForm form){
        ResponseBean response = sysLogService.listLog(form);
        return ResponseEntity.status(response.getStatus()).body(response);
    }

    @ApiOperation("02 使用频次统计")
    @GetMapping(value = "/user")
    public ResponseEntity<ResponseBean> userLogRate(UserLogRateForm form){
        ResponseBean response = sysLogService.userLogRate(form);
        return ResponseEntity.status(response.getStatus()).body(response);
    }

    @ApiOperation("03 个人图表")
    @GetMapping(value = "/chart")
    public ResponseEntity<ResponseBean> userLogChart(UserLogChartForm form){
        ResponseBean response = sysLogService.userLogChart(form);
        return ResponseEntity.status(response.getStatus()).body(response);
    }
}
